package com.vin.rabbitmq.examples;


import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * <br>
 *
 * @author levin
 * @version 1.0.0
 */
public class Test {

    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.MILLISECONDS,
                new SynchronousQueue<Runnable>());
        for (int i = 0; i < 100; i++) {
            try {
                threadPoolExecutor.execute(() -> {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName());
                });
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
//        try {
//            Thread.sleep(200);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        threadPoolExecutor.execute(() -> {
//            try {
//                Thread.sleep(100);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//            System.out.println(Thread.currentThread().getName());
//        });


        System.out.println("提交我完了");
        Thread.sleep(10000);
        System.out.println("休息好了");

    }
}
